<?php
namespace App\Http\Controllers\v1;

use Illuminate\Http\Request;
use Mockery\Exception;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Controllers\RequestBackController;
use App\Http\Controllers\Controller;
use App\Http\Controllers\CheckController;
/*
   系统显示接口
*/
class SystemController extends Controller{
    /*
        系统显示
    */
    public function ShowSystem($request){
        if(!CheckController::CheckUser($request)){
            return RequestBackController::Structure(205);
        }
        $pos=$request->all();
        $systemName = DB::connection('mysql_other')->table('yl_group')->select('group_id as GroupId','group_longName as GroupLongName','group_tel as GroupTel','group_address as GroupAddress','group_name as GroupName')->where('group_id',1)->get()->toArray();
       // var_dump($systemName);
        if($systemName){
            return RequestBackController::Structure(501,$systemName);
        }else{
            return RequestBackController::Structure(504);
        }
            

   
    }

    /*
    编辑系统显示
    */
    public function EditSystem($request){
        if(!CheckController::CheckUser($request)){
            return RequestBackController::Structure(205);
        }
        $pos=$request->all();
        if(!CheckController::CheckParameter($pos,['GroupId'])){//
           return RequestBackController::Structure(502);
       }else{
            $inarr = array();
            $inarr['group_longName'] = $pos['GroupLongName'];
            $inarr['group_tel'] = $pos['GroupTel'];
            $inarr['group_address'] = $pos['GroupAddress'];
            $inarr['group_name'] =$pos['GroupName'];
            $MsgInfo = DB::connection('mysql_other')->table('yl_group')->where('group_id',$pos['GroupId'])->update($inarr);
           if($MsgInfo){
                return RequestBackController::Structure(601);
           }else{
                return RequestBackController::Structure(602);
           }

       }


    }

















   
}